home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Eagles Nest BBS 8
/
Eagles_Nest_Mac_Collection_Disc_8.TOAST
/
Developer Tools⁄Additions
/
InsideBa1994
/
InsideBasic-94
/
IB 94
/
Speech Mgr
/
SpeechDialog.MAIN
< prev
next >
Wrap
Text File
|
1993-09-22
|
3KB
|
112 lines
' FILE: SPEECHDIALOG.MAIN
'______________________________________________
' Speech Manager Demo 3 ©1993 Ariel Publishing
' by Raoul Watson
'______________________________________________
WINDOW OFF : COORDINATE WINDOW : WIDTH -2
COMPILE 1,8
GLOBALS "SPEECH2.GLBL"
END GLOBALS
INCLUDE "SPEECH.TLBX"
DIM mystring$
DIM Malechan&,Femalechan& 'the channels
DIM malename$,femalename$
' calculate the length of the
' VoiceDescription record
infolength&=@infolength&-@VoiceDescription
WINDOW 1,"Speech Dialog Test"
TEXT 4,9,,8
IF SYSTEM(_sysVers)< 605 THEN PRINT "Requires System 6.05 or >.":STOP
Result = FN GESTALT(_"ttsc")
LONG IF (Result AND 1)
PRINT "Text To Speech Component present and ready."
PRINT "SpeechMgr version";FN SpeechManagerVersion/256
XELSE
PRINT "Sorry, Text To Speech Component not available.":STOP
END IF
OSErr=FN CountVoices(@numVoices)
LONG IF OSErr=0
PRINT "There are";numVoices;"voices available."
XELSE
PRINT "CountVoices OSErr=";OSErr:STOP
END IF
' Here we use the default system voice
mystring$="Welcome to Inside BASIC!"
OSErr=FN SpeakString(@mystring$)
' While the default voice is speaking
' asynchronously, we search for two
' voices having male and female attributes
MaleFound=0
FemaleFound=0
FOR i=1 TO numVoices
OSErr = FN GetIndVoice(i,@VoiceSpec)
LONG IF OSErr=_noErr
OSErr = FN GetVoiceDescription(@VoiceSpec,@VoiceDescription,infolength&)
LONG IF OSErr=_noErr
' if found male or female, assign a channel
IF gender =_kMale THEN GOSUB "getMVoice"
IF gender =_kFemale THEN GOSUB "getFVoice"
' check if we have found two voices
IF MaleFound AND FemaleFound THEN i=numVoices'terminate loop
XELSE
PRINT "OSErr GetVoiceDescription =";OSErr:STOP
END IF
XELSE
PRINT "OSErr GetIndVoice =";OSErr:STOP
END IF
NEXT i
' Wait until the first phrase is finished
WHILE FN SpeechBusy
WEND
' now conduct some dialog
mystring$="Hello "+femalename$+". It is good to see you."
OSErr=FN SpeakText(Malechan&,@mystring$+1,LEN(mystring$))
WHILE FN SpeechBusy:WEND
mystring$=Malename$+"I haven't seen you in ages!"
OSErr=FN SpeakText(Femalechan&,@mystring$+1,LEN(mystring$))
WHILE FN SpeechBusy:WEND
mystring$="Well, you know, work, wife, kids, sure keep you busy."
OSErr=FN SpeakText(Malechan&,@mystring$+1,LEN(mystring$))
WHILE FN SpeechBusy:WEND
mystring$="I know exactly what you mean!"
OSErr=FN SpeakText(Femalechan&,@mystring$+1,LEN(mystring$))
WHILE FN SpeechBusy:WEND
IF Malechan& THEN OSErr=FN DisposeSpeechChannel(Malechan&)
IF Femalechan& THEN OSErr=FN DisposeSpeechChannel(Femalechan&)
END
"getMVoice"
IF MaleFound THEN RETURN 'we already have a male voice
malename$=voiceName$
OSErr=FN NewSpeechChannel(@VoiceSpec,@Malechan&)
IF OSErr THEN PRINT "OSErr NewSpeechChannel =";OSErr:STOP
MaleFound=_zTrue
RETURN
"getFVoice"
IF FemaleFound THEN RETURN 'we already have a female voice
femalename$=voiceName$
OSErr=FN NewSpeechChannel(@VoiceSpec,@Femalechan&)
IF OSErr THEN PRINT "OSErr NewSpeechChannel =";OSErr:STOP
FemaleFound=_zTrue
RETURN